<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="cn.sumpu.app.guoguojie.domain.AdminUser,cn.sumpu.app.guoguojie.web.util.AdminUtil" %>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<%
	String name = AdminUtil.getRealname();
	request.setAttribute("name",name);
%>
<script type="text/javascript">
$(function() {
	$(".h_page").pager(
			{
				pagenumber : '${pmUserInfo.currentPage}',
				pagecount : '${pmUserInfo.totalPage}',
				buttonClickCallback : function(page) {
					$(".h_page").hide();
					$("#div_userinfo_list").html("<font color=red>数据加载中......</font>");
					$("#div_userinfo_list").load("/misc/user/getUserInfo.htm",{
						memberId:"${memberId}",
						nickname:"${nickname}",
						sex:"${sex}",
						page:page,
						pageSize:"${pageSize}",
						orderBy:"${orderBy}",
				  		sort:"${sort}",
				  		enabled:"${enabled}"
					},function(){
						$("#page").show();
					});
				}
			});
	$('#user_table_list td').css({
		'height':'50px',
		'padding':'5px',
		'text-align':'center'
	});
	$('.first_td').css({
		'vertical-align':'middle',
		'text-align':'left'
	});
	
});
function enterCover(nickname){
	
	window.open("/misc/user/cover.htm?nid="+encodeURI(nickname));
}

//禁用  
function disEnabled(userid){
	$.get("/misc/user/setIsActive.htm?userid="+userid+"&enabled=false",function(data){
		if(data=="success"){
			$("#td"+userid).html("已禁用<a href='javascript:void(0)' onclick='enabled(&#39;"+userid+"&#39;)'>激活</a>");
		}
	});
}

//激活
function enabled(userid){
	$.get("/misc/user/setIsActive.htm?userid="+userid+"&enabled=true",function(data){
		if(data=="success"){
			$("#td"+userid).html("已激活<a href='javascript:void(0)' onclick='disEnabled(&#39;"+userid+"&#39;)'>禁用</a>");
		}
	});
}
//加入小号
function isSuperSon(userid){
	$.get("/misc/user/isSuperSon.htm?userid="+userid+"&isSon=true",function(data){
		if(data=="success"){
			alert("成功加入小号");
		}
	});
}

</script>

<c:if test="${not empty pmUserInfo.list }">
<c:if test="${pmUserInfo.totalPage>1}">
		<div id="page" class="h_page"></div>
	</c:if>
<div>
	<c:set var="totalDoingCount" value="0"/>
	<c:set var="totalReplyCount" value="0"/>
	<c:set var="totalPictorialCount" value="0"/>
	<c:set var="totalLoginCount" value="0"/>
	<table border="1" id="user_table_list" style="display: block;">
		<tr style="color: black;font-size: 13px" align="center"><td colspan="12">用户信息</td></tr>
		<tr>
			<td class="first_td">用户名</td>
			<td>用户ID</td>
			<td>微博数</td>
			<td>回帖数</td>
			<td>画报数</td>
			<td>注册时间</td>
			<td>注册IP</td>
			<td>最后登录IP</td>
			<td>最后登录日期</td>
			<td>总登录次数</td>
			<td>操作</td>
			<c:if test="${name=='superMan'}"><td> 你是超人，只有你有特权 </td></c:if>
		</tr>
		<c:forEach items="${pmUserInfo.list }" var="m">
		<tr>
			<td class="first_td"><a href="javascript:void(0)" onclick="enterCover('${m.nickname}');">${m.nickname }</a></td>
			<td>${m.identifier }</td>
			<td>${m.doingCount }</td>
			<td>${m.replyCount }</td>
			<td>${m.pictorialCount }</td>
			<td><fmt:formatDate value="${m.registerTime }" pattern="yyyy年MM月dd日 hh:mm:ss"/></td>
			<td>${m.registerIP }</td>
			<td>${m.loginIP }</td>
			<td><fmt:formatDate value="${m.loginTime }" pattern="yyyy年MM月dd日 hh:mm:ss"/></td>
			<td>${m.loginCount }</td>
			<td id="td${m.identifier}">
				<c:if test="${m.enabled == true}">已激活<a href="javascript:void(0)" onclick="disEnabled('${m.identifier}');">禁用</a></c:if>
				<c:if test="${m.enabled == false}">已禁用<a href="javascript:void(0)" onclick="enabled('${m.identifier}');">激活</a></c:if>
			</td>
			<c:if test="${name=='superMan'}"><td> <a href="javascript:void(0)" onclick="isSuperSon('${m.identifier}');">加入小号</a>  </td></c:if>
			<c:set var="totalDoingCount" value="${totalDoingCount+m.doingCount }" />
			<c:set var="totalReplyCount" value="${totalReplyCount+m.replyCount }" />
			<c:set var="totalPictorialCount" value="${totalPictorialCount+m.pictorialCount }" />
			<c:set var="totalLoginCount" value="${totalLoginCount+m.loginCount }"/>
		</tr>
		</c:forEach>
	</table>
	<div>微博总数：${totalDoingCount } 回复总数：${totalReplyCount } 画报总数：${totalPictorialCount } 登录总数：${totalLoginCount }</div>
	<c:if test="${pmUserInfo.totalPage>1}">
		<div id="page" class="h_page"></div>
	</c:if>
</div>
</c:if>
